#ifndef MYTHREAD_H
#define MYTHREAD_H

#include <QThread>
#include <QVector>
#include <QRunnable>
#include <QObject>

#include <QTimer>

////////////////////////////////////////////////////////////
class Generate : public QObject, public QRunnable
{
    Q_OBJECT
public:
    explicit Generate(QObject *parent = 0); // 构造函数

    void recvNum(int num);  // 接受数据

    void run() override;

signals:
    void sendArray(QVector<int> num);


private:
    int m_num;

public slots:
    void handleTimeout();  //超时处理函数
    void handleTimeout2();  //超时处理函数
private:
    QTimer *m_pTimer, *m_pTimer2;
};

////////////////////////////////////////////////////////////
class BubbleSort : public QObject, public QRunnable
{
    Q_OBJECT
public:
    explicit BubbleSort(QObject *parent = 0);

    void recvArray(QVector<int> list);

    void run() override;

signals:
    void finish(QVector<int> num);  // 排序完成

public slots:


private:
    QVector<int> m_list;
};

////////////////////////////////////////////////////////////
class QuickSort : public QObject, public QRunnable
{
    Q_OBJECT
public:
    explicit QuickSort(QObject *parent = 0);

    void recvArray(QVector<int> list);

    void run() override;

signals:
    void finish(QVector<int> list);  // 排序完成

public slots:


private:
    void quickSort(QVector<int> &list,int l, int r);   // 快速排序的递归函数
    QVector<int> m_list;
};

#endif // MYTHREAD_H
